package br.ufmg.dcc.vod.remoteworkers.processor;

import java.io.Serializable;

import br.ufmg.dcc.vod.remoteworkers.Command;

public class WorkHandle implements Serializable {

	private final String internalHandle;
	
	@SuppressWarnings("unchecked")
	private final Command command;

	@SuppressWarnings("unchecked")
	public WorkHandle(Command command, String internalHandle) {
		this.command = command;
		this.internalHandle = internalHandle;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((internalHandle == null) ? 0 : internalHandle.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		WorkHandle other = (WorkHandle) obj;
		if (internalHandle == null) {
			if (other.internalHandle != null)
				return false;
		} else if (!internalHandle.equals(other.internalHandle))
			return false;
		return true;
	}

	public Command getCommand() {
		return this.command;
	}

	public String getInternal() {
		return internalHandle;
	}
}
